<template>
	<view>
		<dcp-scroller :isLoading="isLoading" @refresh="refresh">	
		<view class="page_height_box">
		<view v-if="info==null">
			<zero-loading type="triangle"></zero-loading>
		</view>
		<view v-if="info!=null">
			<view class="info_box">
				<view class="info_title" v-if="id==1">
					隐私政策
				</view>
				<view class="info_title" v-if="id==2">
					用户服务协议
				</view>
				<view class="info_title" v-if="id==3">
					保证金扣除规则
				</view>
				<view class="info_title" v-if="id==4">
					结算细则
				</view>
				<view class="info_title" v-if="id==5">
					奖励规则
				</view>
				<view class="info_title" v-if="id==6">
					骑士安全管理规则
				</view>
				<view class="info_title" v-if="id==7">
					骑士管理说明
				</view>
				<view class="info_title" v-if="id==8">
					违禁品规定
				</view>
				<view class="info_title" v-if="id==9">
					骑手须知协议一
				</view>
				<view class="info_title" v-if="id==10">
					骑手须知协议二
				</view>
				<view class="info_title" v-if="id==11">
					骑手须知协议三
				</view>
				<view class="info_title" v-if="id==12">
					骑手须知协议四
				</view>
				<view class="info_title" v-if="id==13">
					骑手须知协议五
				</view>
				<view class="info_title" v-if="id==14">
					骑手须知协议六
				</view>
				<view class="info_title" v-if="id==15">
					培训中心
				</view>
				<view class="info_title" v-if="id==16">
					安全中心
				</view>
				<view class="desc_box">
					<jyf-parser :html="content" ref="article" :tag-style="tagStyle"></jyf-parser>
				</view>
			</view>
			<view style="height: 20rpx;"></view> 
		</view>
		</view>
		</dcp-scroller>
	</view>
</template> 
  
<script>
	import jyfParser from "@/components/jyf-parser/jyf-parser";
	import zeroLoading from "@/components/zero-loading/components/zero-loading/zero-loading.vue"
	export default {
		components: {
			jyfParser,
			zeroLoading
		},
		data() {
			return {
				isLoading:false,
				id:0,
				content:'',
				info:null,
				tagStyle: {
					img: 'display: block;width: 100%!important;height:auto!important;',
					p:'margin-bottom: 10rpx;line-height: 50rpx;'
				},
			};
		},
		onLoad(e) {
			var a =this
			a.id = e.id
			a.getArticle()
		},
		onPullDownRefresh(){
			var a = this
			a.getArticle()
		},
		methods:{
			refresh(){
				var a = this
				a.isLoading = true;
				setTimeout(()=>{
					a.getArticle()
				},200)
			},
			getArticle(){
				var a =this 
				var temp_value = ''
				if(a.id==1){
					temp_value = 'privacy_agreement'
				}else if(a.id==2){
					temp_value = 'user_service_agreement'
				}else if(a.id==3){
					temp_value = 'deposit_rule'
				}else if(a.id==4){
					temp_value = 'settlement_info'
				}else if(a.id==5){
					temp_value = 'reward_rule'
				}else if(a.id==6){
					temp_value = 'rider_safety_rule'
				}else if(a.id==7){
					temp_value = 'rider_manger_rule'
				}else if(a.id==8){
					temp_value = 'contraband_rule'
				}else if(a.id==9){
					temp_value = 'agreement1'
				}else if(a.id==10){
					temp_value = 'agreement2'
				}else if(a.id==11){
					temp_value = 'agreement3'
				}else if(a.id==12){
					temp_value = 'agreement4'
				}else if(a.id==13){
					temp_value = 'agreement5'
				}else if(a.id==14){
					temp_value = 'agreement6'
				}else if(a.id==15){
					temp_value = 'agreement9'
				}else if(a.id==16){
					temp_value = 'agreement10'
				}
				a.globalajax('common/getConfig',{
					value:temp_value
					},'GET',function(res) {
						console.log(res);
						a.isLoading = false
						uni.stopPullDownRefresh()
						uni.hideLoading()
						if(res.data.code==200){
							a.info = res.data.data
							const regex = new RegExp('<img', 'gi');
							var richtext = res.data.data
							richtext = richtext.replace(/<table[^>]*>/gi, '<table cellpadding="0" cellspacing="0" max-width="100%" border="1" style="font-size:12px;max-width:100%; text-align:left;text-indent: 0em;line-height:12px;">'); 
							a.content = richtext.replace(regex, `<img style="max-width: 100%;"`);	
						}else{	
							a.$showModal({
								title:'友情提示',
								content:res.data.msg,
								showCancel:false,
								confirmText:'我知道了',
								success: (res) => {
								}
							}); 
						}
					}
				);
			},
		}
	}
</script>

<style lang="scss">
page{
	background-color: #fff;
}
.info_box{
	width: 694rpx;
	padding: 0rpx 0rpx 30rpx 0rpx;
	margin: 0 auto;
	.info_title{
		font-size: 42rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 68rpx;
		letter-spacing: 0rpx;
		color: #333333;
	}
	.desc_box{
		font-size: 30rpx;
		line-height: 60rpx;
		letter-spacing: 0rpx;
		color: #333333;
		padding-top: 30rpx ;
		word-break: break-all;
		white-space:normal; 
		word-wrap:break-word;
		word-break:break-word;
	}
}

</style>
